Skip to content

optimize cp gdn#128

Open
Jintao-Huang wants to merge 1 commit into
modelscope:mainfrom
Jintao-Huang:optimize_cp_gdn
Open

optimize cp gdn#128
Jintao-Huang wants to merge 1 commit into
modelscope:mainfrom
Jintao-Huang:optimize_cp_gdn

Conversation

@Jintao-Huang

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request optimizes the GatedDeltaNet module by introducing a fused THD AlltoAll path (using a single AlltoAll and sequence permutation) when _build_thd_cp_a2a_perm is available, falling back to the per-sequence loop otherwise. Feedback suggests using the local variable cp_size instead of self.cp_size in the fallback path to ensure consistency and avoid potential AttributeErrors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

qkvzba = qkvzba.index_select(0, thd_cp_a2a_idx)
else:
# Fallback: per-sequence loop
unpacked_qkvzba = _unpack_sequence(qkvzba, cu_seqlens // self.cp_size, dim=0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use the local variable cp_size instead of self.cp_size for consistency with the rest of the method and to avoid potential AttributeError if self.cp_size is not defined on the parent class.

Suggested change
unpacked_qkvzba = _unpack_sequence(qkvzba, cu_seqlens // self.cp_size, dim=0)
unpacked_qkvzba = _unpack_sequence(qkvzba, cu_seqlens // cp_size, dim=0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant